<layout name="layout" />
<div class="pageheader notab">
 <h1 class="pagetitle" id="campaign_title">全店健康诊断</h1>
 <ul class="breadcrumbs breadcrumbs2">
      <li>全店健康诊断</li>
  </ul>
</div>
     
<div id="contentwrapper" class="contentwrapper nopadding">
    <div>
    	<a id="startCheck" class="actionBtn" href="javascript:void(0);" style="margin-left:0px;">开始全店诊断</a>
    	
    	<div id="analytics_progress" style="width:250px;display:none;">
	   		<div class="progress">
	           <div class="bar"><div class="value bluebar" style="width: 5%;"></div></div>
	        </div>
	    </div>
	    
		<div id="need_analytics">
			<if condition='$last_time eq 0'>
			尚未进行健康诊断，请点击健康诊断按钮进行请先进行诊断后再查看
			</if>
		</div>	
		
    </div>
    
    <br class="clearall" />
	
<if condition='$last_time neq 0'>
	<div class="" >
		<h5 style="margin: 20px 0 0px" class="campaign_select_title">常规健康概况 (最后诊断时间: {$last_time})</h5>
	
		<table cellspacing="0" cellpadding="0" border="0" class="metrotable bluehead healthtable">
           <tbody>
           	   <volist name="keyword_industry_report" id="v">
               <tr>
                   <td width="50%">
                   		<div class="row-fluid">
                   			<div class="span4">
                 				<p>{$v.name}</p>
                  				<span class="heavy orange" >{$v.value}</span>
                   			</div>
                   			
                   			<div class="span4">
                   				<p>同行业{$v.name}</p>
                   				<span class="heavy">{$v.avg}</span>
                   			</div>
                   			<div class="span4">
                   				<p>超过了<span class="medium">{$v.ratio}%</span>同行卖家</p>
                   			</div>
                   		</div>
                   	</td>
                   <td width="15%">
                   		<span class="label {$v.css}">{$v.text}</span>
                   </td>
                   
                   <td style="padding-left:20px;" width="35%">
                   		<ul class="">
                   			<volist name="v.reason" id="r">
                   			<li>
                   				{$r}
                   			</li>
                   			</volist>
                   		</ul>
                   </td>
               </tr>
               </volist>
           </tbody>
       </table>
       
       <h5 style="margin: 20px 0 0px" class="campaign_select_title">关键词健康概况 (最后诊断时间: {$last_time})</h5>
		
		<table cellspacing="0" cellpadding="0" border="0" class="metrotable bluehead healthtable">
           <tbody>
               <tr>
                   <td width="50%">
                   		<div class="row-fluid">
                   			<div class="span4">
                 				<p>{$keywords_price_report.name}</p>
                  				<span class="heavy orange" >￥{$keywords_price_report.value}</span>
                   			</div>
                   			
                   			<div class="span4">
                   				<p>{$keywords_price_report.compare_name}</p>
                   				<span class="heavy">￥{$keywords_price_report.avg}</span>
                   			</div>
                   			
                   			<div class="span4">
                   			    <ul class="actlist horizon">
                   					<volist name="keywords_cats_price_report" id="cat" >
                   						<li>
                   							{$cat.name}
                   							<span class="heavy">￥{$cat.avg}</span>
                   						</li>
                   					</volist>
                   				</ul>
                   			</div>
                   		</div>
                   	</td>
                   <td  width="15%">
                   </td>
                   
                   <td style="padding-left:20px;" width="35%;">
                   </td>
               </tr>
               
           	   <volist name="keywords_indicators_report" id="v">
               <tr>
                   <td width="50%">
                   		<div class="row-fluid">
                   			<div class="span4">
                 				<p>{$v.name}</p>
                  				<span class="heavy orange" >{$v.value}</span>
                   			</div>
                   			
                   			<div class="span4">
                   				<p>{$v.compare_name}</p>
                   				<span class="heavy">{$v.avg}</span>
                   			</div>
                   		</div>
                   	</td>
                   <td  width="15%">
                   </td>
                   
                   <td style="padding-left:20px;" width="35%;">
                   		<ul class="">
                   			<volist name="v.reason" id="r">
                   			<li>
                   				{$r}
                   			</li>
                   			</volist>
                   		</ul>
                   </td>
               </tr>
               </volist>
               
           	   <volist name="keywords_statistic_report" id="v">
               <tr>
                   <td width="50%">
                   		<div class="row-fluid">
                   			<div class="span4">
                 				<p>{$v.name}</p>
                  				<span class="heavy orange" >{$v.total}</span>
                   			</div>
                   			
                            <div class="span4">
                     			 <p>占全部<span class="medium">{$v.ratio|display_ratio}%</span>关键词</p>
                   			</div>
                   			
                   			<div class="span4">
                   			  <p>{$v.compare}</p>
                   			   <ul class="actlist horizon">
                   					<volist name="v.cates" id="sub_cate" >
                   						<li>
                   							{$sub_cate.name}
                   							<span class="heavy">{$sub_cate.total}</span>
                   						</li>
                   					</volist>
                   				</ul>   
                   			</div>
                   			

                   		</div>
                   	</td>
                   <td  width="15%">
                   </td>
                   
                   <td style="padding-left:20px;" width="35%;">
                   		<ul class="">
                   			<volist name="v.reason" id="r">
                   			<li>
                   				{$r}
                   			</li>
                   			</volist>
                   		</ul>
                   </td>
               </tr>
               </volist>
 
           </tbody>
       </table>       
       
	</div>
	
</div>

</if>

<script type="text/javascript">
	$("#startCheck").bind("click" , function(){
		var $btn = $(this);
		$btn.disabled();
		$btn.text("正在健康诊断中，请稍后查看");
		var progress_bar = $("#analytics_progress");
		$("#need_analytics").html(
			'<img src="/Img/loader1.gif" /> 正在诊断中，需要一点时间,你可以离开本页面稍后回来查看'		
		);
		progress_bar.show();
		wt.get('/optimize/analyze');
		var statusCheck =  setInterval( function(){
			$.get('/optimize/progress' , function(r){
				var o = $.parseJSON(r);
				if( o.data ){
					progress_bar.find('.bluebar').css( 'width' , o.data + '%');
				}
				
				if(o.data == 100){
					$btn.recover();
					$btn.text("开始健康检查");
					$("#need_analytics").showMsg('分析完成' , 'yes');
					clearInterval(statusCheck);
					document.location.reload(true);
				}
			});
		}, 1000);
	});
</script>